
package com.mybatis.generator;

import com.mybatis.generator.core.Context;
import com.mybatis.generator.core.FreemarkerUtils;
import com.mybatis.generator.core.JavaBeanUtils;
import com.mybatis.generator.core.Table;

public class MapperGenerator {
	
	private static final String TEMPLATE_NAME = "freemaker-mapper";

	public static void process(Context ctx, Table table) throws Exception {
		StringBuilder sb = new StringBuilder(ctx.getMapper());
		sb.append(JavaBeanUtils.splitString(table.getPackageName()));
		sb.append("/dao/");
		sb.append(table.getMapperName()).append(".java");
		FreemarkerUtils.write(sb.toString(),
				FreemarkerUtils.process(TEMPLATE_NAME, table));
	}

}
